package org.webscale.json.cmd;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;

public class PingCommand extends AbstractAppEngineCmd {

	private static final Logger log = Logger.getLogger(PingCommand.class.getName());
	

	public AppEngineCmdResults execute(String[] params) {
		log.info("Command Received with Params");
		Calendar c =Calendar.getInstance();
		DateFormat format = DateFormat.getDateInstance(DateFormat.LONG);
		String dt = format.format(c.getTime());
		String ret ="Pinging Back at " + dt + " ...\n";
		ret += getJavaDetails();
		AppEngineCmdResults results = new AppEngineCmdResults();
		results.setStatus(true);
		results.setResponse(ret);
		return results;
	}
	
	public String getJavaDetails(){
		String str="Not Available";
		Map<String, String> env = System.getenv();
		Set<String> keys =env.keySet();
		for(String s: keys){
			str +=" " + s + " = " + env.get(s) + "\n";
		}
		 return str;
	}

}